<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title>教师登录</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<link rel="stylesheet" href="../../css/layui.css" media="all">
		<script src="../../js/jquery.min.js"></script>
		<script src="../../js/vue.min.js"></script>
	</head>

	<body>

		<div class="layui-container" id="app">
			<div class="layui-row ">
				<fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
					<legend>教师登录</legend>
				</fieldset>

				<div class="layui-col-md-offset3" style="margin-top: 100px;">
					<form class="layui-form" action="" @submit.prevent="submit">

						<div class="layui-form-item ">

							<label class="layui-form-label"><i class="layui-icon layui-icon-username" ></i>  </label>
							<div class="layui-input-inline">
								<input type="text" name="username" v-model="username" lay-verify="title" autocomplete="off" placeholder="请输入工号" class="layui-input">
							</div>
						</div>

						<div class="layui-form-item">
							<label class="layui-form-label"><i class="layui-icon layui-icon-password" ></i></label>
							<div class="layui-input-inline">
								<input type="password" name="password" v-model="password" lay-verify="pass" placeholder="请输入密码" autocomplete="off" class="layui-input">
							</div>
							<div class="layui-form-mid layui-word-aux"></div>
						</div>
						<div class="layui-form-item">
							<label class="layui-form-label"><i class="layui-icon layui-icon-vercode" ></i></label>
							<div class="layui-input-inline">
								<input type="text" name="verify" v-model="verify" lay-verify="required" placeholder="请输入验证码" autocomplete="off" class="layui-input">
							</div>
						</div>

						<div class="layui-form-item">
							<div class="layui-input-block">
								<button class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
								<button type="reset" class="layui-btn layui-btn-primary">重置</button>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>

		<div class="layui-container">
			<div class="layui-fluid">

			</div>
		</div>

		<script src="../../layui.js" charset="utf-8"></script>
		<script src="../../js/jquery.cookie.js"></script>
		<script>
			layui.use(['form', 'layedit', 'laydate'], function() {
				var form = layui.form,
					layer = layui.layer,
					layedit = layui.layedit,
					laydate = layui.laydate;

				//自定义验证规则
				form.verify({
					title: function(value) {
						if(value.length < 5) {
							return '工号不正确';
						}
					},
					pass: [/(.+){6,20}$/, '密码必须6到20位'],
					content: function(value) {
						layedit.sync(editIndex);
					}
				});


			});
		</script>
		
		<script>
			var vue = new Vue({
				el:"#app",
				data:{
				    username:"",
					password:"",
                    verify:""
				},
                methods: {
                    submit : function() {
                        $.ajax({
                        	xhrFields: {
						        withCredentials: true
						    },
                            url:"http://localhost:8080/teacher/teacherLogin/test.do",
                            type:"get",
                            dataType:"json",
                            data:{
                                teaNum:vue.username,
								teaPwd:vue.password,
                                verify:vue.verify,
                                uid:$.cookie("uid")
							},
                            async:false,
                            success:function(data){
                                alert(123)
                                alert(data)
                            },
                            error:function (data) {
								alert(666)
								window.location.href = '../backindex.html';
								return false;
                            }
                        });
                    }
                }
			})
		</script>
	</body>

</html>
